define(
	[
		'require',
		'./performance_ctrl'
	],
	function(require){
		 function actionFormatter(value, row, index) {

	        return '<div class="" style="text-align:left">'+APM.util.escape(value)+'</div>';
	    }
		var Controller = require('./performance_ctrl').extend({
			formTitle: "系统可用性报表",
			itemData: Ember.A(["appAvailableRate"]),
			arrayData: Ember.A(["appInterruptTime","appInterruptCount"]),
			lineData: Ember.A(["business/success/count","business/success/rate"]),
			columns: [
			  [  {
			    "field": "appName",
			    "title": "系统名称",
			    formatter:actionFormatter,
			    "colspan": 1,
			    "rowspan": 2,
			    // "sortable": true

			  }
			  , {
			    "title": "系统可用性",
			    "colspan": 4,
			    "rowspan": 1
			  },
			  {
			    "title": "交易成功率",
			    "colspan": 5,
			    "rowspan": 1
			  }], 
			  [{
			    "field": "appAvailableRate",
			    "title": "可用率%",
			    "colspan": 1,
			    "rowspan": 1,
			    // "sortable": true
			  }, {
			    "field": "appServerTime",
			    "title": "提供服务总时间（分钟）",
			    "colspan": 1,
			    "rowspan": 1,
			  }, {
			    "field": "appInterruptTime",
			    "title": "服务中断时间（分钟）",
			    "colspan": 1,
			    "rowspan": 1,

			  }, {
			    "field": "appInterruptCount",
			    "title": "服务中断次数",
			    "colspan": 1,
			    "rowspan": 1,
			  }, {
			    "field": "business/throughput/total",
			    "title": "交易总量",
			    "colspan": 1,
			    "rowspan": 1,

			  }, {
			    "field": "business/success/count",
			    "title": "成功交易量",
			    "colspan": 1,
			    "rowspan": 1,
			  }, {
			    "field": "business/success/rate",
			    "title": "成功率%",
			    "colspan": 1,
			    "rowspan": 1,

			  }, {
			    "field": "history_business/throughput/total",
			    "title": "上期交易量",
			    "colspan": 1,
			    "rowspan": 1,
			  }, {
			    "field": "business/throughput/total_rate",
			    "title": "变化率",
			    "colspan": 1,
			    "rowspan": 1,
			  }]
			],
			reportformData: function(){

				var ctrl = this;
				var params = {
					"startDate": +this.get("startDate"),
					"endDate": +this.get("endDate")
				}
				clearTimeout(ctrl.get("clearTime"));
				var newArray = [],
					newObject;

				ctrl.set("tipTitle","");

				return this.store.ajax("GET", "report/system/availability",params)
				.then(function(response){
					var performances = response.performances;
					
					if(!performances[0]){
						ctrl.set("tipTitle","这段时间内暂无数据");
					}
					ctrl.set("groupData",performances);
					
				});
			},
			url:"report/system/availability/download",
		});

		APM.FormAvailabilityController = Controller;
		return Controller;
	}
);